from django.db import models

class Category(models.Model):
  name = models.CharField(maxlength=200)
  slug = models.SlugField(maxlength=200, prepopulate_from=("name",))
  def __str__(self):
    return self.name
  class Admin:
    pass

class Topic(models.Model):
  name = models.CharField(maxlength=200)
  slug = models.SlugField(maxlength=200, prepopulate_from=("name",))
  category = models.ForeignKey(Category)
  def __str__(self):
    return self.name
  class Admin:
    list_display = ("name", "category")
    list_filter = ("category",)
    pass

class Content(models.Model):
  title = models.CharField(maxlength=200)
  slug = models.SlugField(maxlength=200, prepopulate_from=("title",))
  topic = models.ForeignKey(Topic)
  url = models.URLField(maxlength=1000)
  date = models.DateField()
  source = models.CharField(maxlength=200)
  interviewer = models.CharField(maxlength=200)
  summary = models.CharField(maxlength=1000)
  type = models.CharField(maxlength=50)
  fulltext = models.TextField(default='')
  rating = models.FloatField(default=0, max_digits=2, decimal_places=1)
  allow_full_text = models.BooleanField(default=False)
  def __str__(self):
    return self.title
  class Admin:
    list_display = ("title", "date", "source", "type")
    #fields = ((None, {'fields': ('title', 'slug', 'url', 'date', 'editor', 'comment', 'tags', 'text',)}),)  
    pass
